package com.xgq.drink.controller;

import com.xgq.drink.entity.R;
import com.xgq.drink.entity.dto.CategoryTreeDTO;
import com.xgq.drink.utils.RUtils;
import com.xgq.drink.service.impl.CategoryService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xgq
 * @since 2025-02-23
 */
@RestController
@RequestMapping("/category")
@Tag(name = "分类模块", description = "分类查询接口")
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    @GetMapping("/tree")
    public R getCategoryTree() {
        List<CategoryTreeDTO> tree = categoryService.getCategoryTree();
        return RUtils.success("分类树获取成功", tree);
    }
}
